Namespace Sql
  Public Class Convert
    Private Shared mDataTypes As SortedList(Of String, String)

    Shared ReadOnly Property TypeMask(ByVal dataType As String) As String
      Get
        If mDataTypes Is Nothing Then
          mDataTypes = New SortedList(Of String, String)
          ' --- datatype -----------------------------------------------------
          ' 0: Type
          ' 1: Length
          ' 2: Length == -1 ? MAX : Length
          ' 3: Precision
          ' 4: Scale

          mDataTypes.Add("bigint", "{0}")
          mDataTypes.Add("bit", "{0}")
          mDataTypes.Add("datetime", "{0}")
          mDataTypes.Add("float", "{0}")
          mDataTypes.Add("int", "{0}")
          mDataTypes.Add("money", "{0}")
          mDataTypes.Add("real", "{0}")
          mDataTypes.Add("smalldatetime", "{0}")
          mDataTypes.Add("smallint", "{0}")
          mDataTypes.Add("smallmoney", "{0}")
          mDataTypes.Add("sql_variant", "{0}")
          mDataTypes.Add("sysname", "{0}")
          mDataTypes.Add("timestamp", "{0}")
          mDataTypes.Add("tinyint", "{0}")
          mDataTypes.Add("uniqueidentifier", "{0}")
          mDataTypes.Add("xml", "{0}")
          ' --- datatype(length) ---------------------------------------------
          mDataTypes.Add("binary", "{0}({1})")
          mDataTypes.Add("char", "{0}({1})")
          mDataTypes.Add("nchar", "{0}({1})")
          ' --- datatype(precision,scale) ------------------------------------
          mDataTypes.Add("decimal", "{0}({3},{4})")
          mDataTypes.Add("numeric", "{0}({3},{4})")
          ' --- datatype(MAX) ------------------------------------------------
          mDataTypes.Add("nvarchar", "{0}({2})")
          mDataTypes.Add("varbinary", "{0}({2})")
          mDataTypes.Add("varchar", "{0}({2})")
          ' === Not supported: "ntext", "text", "image" ======================
        End If

        If mDataTypes.ContainsKey(dataType) = True Then
          Return mDataTypes(dataType)
        Else
          Return Nothing
        End If
      End Get
    End Property
  End Class
End Namespace